package com.ling.tts3;

import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.ling.tts3.utils.SystemTTS;
import com.ling.tts3.utils.TTSUtil;

public class TTS3Activity extends AppCompatActivity {

    private static final int MY_DATA_CHECK_CODE = 100;
    private static String TAG = "TTS3Activity";
    // tts
    private SystemTTS tts;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_tts1);

        Button button = findViewById(R.id.test);
        TextView textView = findViewById(R.id.edit);


        tts = SystemTTS.getInstance(this);


        button.setOnClickListener(v -> {
            String text = textView.getText().toString();
            Log.d(TAG,"转换:"+text);
            if (!text.isEmpty()) {
//                Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
                tts.speak(text);
            }
        });

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (tts!= null) {
            tts.destroy();
        }
    }

}